﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TVGuide.DataAccess.Repository
{
    public interface IRepository<T>
    {
        /// <summary>
        ///     Adds an item to repository
        /// </summary>
        /// <param name="item">Item to be added</param>
        void Add(T item);
        /// <summary>
        ///     Adds an item to repository
        /// </summary>
        /// <param name="item">Item to be added</param>
        /// <param name="commitChange">Boolean variable which represents whether to commit change or not</param>
        void Add(T item, bool commitChange);
        /// <summary>
        ///     Adds item range to repository
        /// </summary>
        /// <param name="items">Items' enumeration to be added</param>
        void AddRange(IEnumerable<T> items); 
        /// <summary>
        ///     Returns item by the given unique id
        /// </summary>
        /// <param name="id">Id of the item</param>
        /// <returns></returns>
        T Get(int id);
        /// <summary>
        ///     Returns items by the given conditional function
        /// </summary>
        /// <param name="func">The System.Predicate<T> delegate that defines the conditions of the elements to return</param>
        /// <returns></returns>
        IEnumerable<T> Get(Predicate<T> func);
        /// <summary>
        ///     Returns all items in table
        /// </summary>
        /// <returns>All items' range</returns>
        IEnumerable<T> GetAllItems();
        /// <summary>
        ///     Removes item with corresponding id from table
        /// </summary>
        /// <param name="id">Id of the item</param>
        void Remove(int id);
        /// <summary>
        ///     Removes items corresponding to func
        /// </summary>
        /// <param name="func">The System.Predicate<T> delegate that defines the conditions of the elements to remove
        void Remove(Predicate<T> func);
        /// <summary>
        ///     Removes all items from table
        /// </summary>
        void RemoveAll();
    }
}
